package game.main;

import game.basic.Util;
import game.role.Player;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class GameApp extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    public GamePanel gamePanel;
    public static Player player;
    public static Sound gameMusic;

    // 设置窗口图标
    Image icon;

    @Override
    public void init() {
        player = new Player();
        gameMusic = new Sound();
        icon = Util.getImage("/icon/app.png", 0, 0);
        gamePanel = new GamePanel();
    }

    @Override
    public void start(Stage stage) {
        //设置窗口不可调整大小,设置窗口标题,设置应用程序图标
        stage.setResizable(false);
        stage.setTitle("游戏模板21");
        // 初始化游戏引擎，确保在显示窗口前完成所有初始化工作
        gamePanel.initEngine(stage);
        // 创建StackPane布局并添加Canvas
        BorderPane root = new BorderPane(gamePanel);
        // 设置背景颜色为黑色
        root.setStyle("-fx-background-color: black;");
        // 创建Scene并设置到Stage
        Scene scene = new Scene(root);

        stage.getIcons().add(icon);

        stage.setScene(scene);
        stage.show();
    }
}
